package com.sangeng.controller;

import com.sangeng.domain.ResponseResult;
import com.sangeng.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/article")
public class AticleController {
    @Autowired
    private ArticleService articleService;
//    @GetMapping("/test")
//    public List<Article> test(){
//        return articleService.list();
//    }
    @GetMapping("/hotArticleList")
    public ResponseResult hotArticleList(){
        //查询热门文章 封装成ResponseResult返回
        ResponseResult result=articleService.hotArticleList();
        return result;
    }
    @GetMapping("/articleList")
    public ResponseResult getPageArticleList(Integer pageNum,Integer pageSize,Long categoryId){
        //查询分页文章列表
        ResponseResult result=articleService.getPageArticleList(pageNum,pageSize,categoryId);
        return result;
    }
    @GetMapping("/{id}")
    public ResponseResult getArticleDetail(@PathVariable("id") Long id){
        ResponseResult result=articleService.getArticleDetail(id);
        return result;
    }
    @PutMapping("/updataViewCount/{id}")
    public ResponseResult updataViewCount(@PathVariable("id") Long id){
        ResponseResult result=articleService.updataViewCount(id);
        return  null;
    }
}
